package cn.yunhe.test;

import org.junit.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class ClientRead extends Thread{
    private Socket socket=null;
    public  ClientRead(Socket socket){
        this.socket=socket;
    }

    public static void main(String[] args) {
        try {
            Socket socket=new Socket("172.16.1.251",8888);
            ClientRead reader=new ClientRead(socket);
            ClientWrite writer=new ClientWrite(socket);
            reader.start();
            writer.start();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public void run(){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true){
                System.out.println( br.readLine());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
